#!/usr/bin/bash

echo "Now, we are going to install the arm development packages"
condition=none
tool_list=(openocd stlink gcc-arm-none-eabi-bin arm-none-eabi-gdb dotnet-sdk-6.0)
to_install=()

for app in ${tool_list[*]}; do
	echo "Do you want to install $app ?"
	while [ $condition != "yes" ] && [ $condition != "no" ]; do
		read -p "(yes/no) " condition
	done
	if [ $condition == "yes" ]; then
		to_install+=($app)
	fi
	condition=none
done

echo -e "\e[36mThe following packages will be installed : ${to_install[*]}\e[0m"
is_install=none
while [ $is_install != "yes" ] && [ $is_install != "no" ]; do
	read -p "continue ? (yes/no) " is_install
done

if [ $is_install == "yes" ]; then
	if [ $to_install[@] =~ "gcc-arm-none-eabi-bin" ]; then
		yay -S ${to_install[*]}
	else
		sudo pacman -S ${to_install[*]}
	fi
	echo -e "\e[32mSuccessfully install ${#to_install[@]} packages !"
	echo "Have a good time with these packages !"
else
	echo -e "\e[33mInstallation abort !\e[0m"
fi
